/*
 *  $Id: TextButton.cs 1099 2010-05-26 15:31:29Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2009 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

using AgateLib.DisplayLib;
using AgateLib.Geometry;

namespace Ragima.UI {
    public class TextButton: OldText {
        private SimpleEvent _action;
        private Color _defColor, _focusColor;

        public TextButton(Rectangle rect, string text, SimpleEvent action): base(rect, text, Color.White) {
            _action = action;
            _defColor = Color.Gray;
            _focusColor = Color.White;
            Padding = 2;
            Alignment = TextAlignment.Center;
        }

        public Color DefColor {
            get { return _defColor; }
            set { _defColor = value; }
        }
        public Color FocusColor {
            get { return _focusColor; }
            set { _focusColor = value; }
        }

        public override void Draw() {
            Color color = Focus ? _focusColor : _defColor;
            Display.DrawRect(Rect, color);
            TextColor = color;
            base.Draw();
        }

        public override void OnClick() {
            if (_action != null)
                _action();
        }
    }
}
